home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 9
/
Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO
/
039a
/
netpq203.zip
/
NETPQ.C
< prev
next >
Wrap
Text File
|
1993-03-18
|
7KB
|
327 lines
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include "nos.h"
#include "noslib.h"
#include "netpq.h"
#include "version.h"
#include "proto.h"
//
// NETPQ.EXE
//
// See Usage () for comments
//
// This program uses the Borland C versions of the nos library included in
// the file 'book.zip' on the Artisoft BBS (602-293-0065) and was compiled
// using Borland C++.
//
// Written by Alan R. Roney
//
// Released into the public domain by the author. The author accepts no
// responsiblity for any problems associated with use of this program.
//
// This software is not to be included in any "for profit" software packages.
//
// You are welcome to modify the source code for this program. Please
// forward a copy of your changes to the author.
//
// Comments and suggested changes should be directed to the author at:
//
// Compuserve: 76330,3711
// Internet: 76330.3711@compuserve.com
// Artisoft: alan roney
//
struct serverdef *server;
struct localqueuedef *localqueue;
int currentserver, adaptornum, numberoflogins, currentprinter, found;
int queuejobcount, printjobcount;
int maxlocalqueuecount, localqueuecount, previouslocalqueuecount;
int monoflag;
int plotterflag;
int timeout;
char servername [D_NAMESZ + 2];
struct PS serverps;
struct queue_entry serverqe;
struct time_block servertime;
struct user_account serveraccount;
void main (int argc, char *argv [])
{
int keypressed, i, j;
int show_title;
char buf [50];
monoflag = false;
plotterflag = false;
show_title = true;
for (i = 1; i < argc; i++)
{
if ( (argv [i] [0] == '-') || (argv [i] [0] == '/') )
{
for (j = 1; argv [i] [j] != '\0' ; j++)
{
switch (argv [i] [j])
{
case 'm':
case 'M':
monoflag = true;
break;
case 'p':
case 'P':
plotterflag = true;
break;
case 'h':
case 'H':
case '?':
Usage ();
exit ();
break;
}
}
}
}
setup ();
timeout = NUM_UPDATES_FOR_TIMEOUT;
previouslocalqueuecount = 0;
do
{
do
{
getserverinfo ();
clrscr ();
reportinfo ();
showmenu ();
if (show_title)
{
sprintf (buf, "NETPQ.EXE Version %d.%02d\0", MAJOR_VERSION, MINOR_VERSION);
message (buf, false);
show_title = false;
}
if (localqueuecount != previouslocalqueuecount)
{
timeout = NUM_UPDATES_FOR_TIMEOUT;
previouslocalqueuecount = localqueuecount;
}
timeout--;
i = 0;
while (i++ < 2)
{
sleep (1);
if (kbhit () != 0)
break;
}
}while ( (kbhit () == 0) && (timeout > 0) );
if (timeout <= 0)
break;
keypressed = getextch ();
switch (keypressed)
{
case key_f1:
f1keypressed ();
timeout = NUM_UPDATES_FOR_TIMEOUT;
break;
case key_f2:
f2keypressed ();
timeout = NUM_UPDATES_FOR_TIMEOUT;
break;
case key_f3:
if (plotterflag)
{
f3keypressed ();
timeout = NUM_UPDATES_FOR_TIMEOUT;
break;
}
default:
keypressed = key_esc;
break;
}
lowvideo ();
}while (keypressed != key_esc);
lowvideo ();
textcolor (LIGHTGRAY);
clrscr ();
free (server);
free (localqueue);
}
void setup ()
{
char *plotterserver = plotterserverstring;
int i;
// Check for presence of NOS Version 4.0 or greater
if (NOSPresence () == -1)
{
printf ("NOS not installed\n");
exit (1);
}
if (NOSGetVersion () < NOS_VERSION)
{
printf ("Incorrect NOS Version\n");
exit (1);
}
// Find out how many servers this node is logged into
numberoflogins = 0;
servername [0] = servername [1] = '\\';
while (NOSGetLogin (&numberoflogins, &servername [2], &adaptornum) != -1)
numberoflogins++;
if (numberoflogins <= 0)
{
printf ("Not logged into to any servers\a\n");
exit (1);
}
// open structures for storing information
if ( (server = (struct serverdef *) calloc (numberoflogins, sizeof (struct serverdef))) == (struct serverdef *) 0)
{
printf ("Couldn't allocate space for server information\n");
exit (1);
}
maxlocalqueuecount = 0;
if ( (localqueue = (struct localqueuedef *) calloc (1, sizeof (struct localqueuedef))) == (struct localqueuedef *) 0)
{
printf ("Couldn't allocate space for queue information\n");
exit (1);
}
// Get server names and queue privileges
currentserver = 0;
i = 0;
while (currentserver < numberoflogins)
{
if (NOSGetLogin (¤tserver, &servername [2], &adaptornum) == -1)
{
NOSperror ("NOSGetLogin");
exit (1);
}
if (
(!plotterflag) ||
(strcmp (servername, plotterserver) == 0)
)
{
strcpy (server [i] .servername, servername);
// Check for queue privileges
if (NOSGetAccount (&serveraccount, servername) == -1)
{
NOSperror ("NOSGetAccount");
exit (1);
}
else
{
if (((serveraccount .UA_privilege & UA_privilege_superACL) != 0) ||
((serveraccount .UA_privilege & UA_privilege_superqueue) != 0))
{
server [i] .queue_privilege = true;
}
else
server [i] .queue_privilege = false;
}
i++;
}
currentserver++;
}
qsort ( (void *) server, i, sizeof (struct serverdef), comparestring);
numberoflogins = i;
}
void showmenu ()
{
textcolor (LIGHTGRAY);
highvideo ();
cprintf ("F1: ");
lowvideo ();
cprintf ("Control Port ");
highvideo ();
cprintf ("F2: ");
lowvideo ();
cprintf ("Control Queue ");
if (plotterflag)
{
highvideo ();
cprintf ("F3: ");
lowvideo ();
cprintf ("Release Plot File ");
}
highvideo ();
cprintf ("Any other key: ");
lowvideo ();
cprintf ("Exit");
}
void Usage ()
{
int i;
printf ("\nNETPQ.EXE Version");
printf (" %d.%02d", MAJOR_VERSION, MINOR_VERSION);
i = BETA_VERSION;
if (i > 0)
printf (".%02d", BETA_VERSION);
printf ("\n\n");
printf ("Displays printer queue activity on all logged on servers. The display\n");
printf (" updates every two seconds. Queued files may be cancelled, held, or\n");
printf (" released by the operator. If the operator has queue privileges, the\n");
printf (" operator can change the downloading status of each printer port and\n");
printf (" may 'rush' queued files.\n\n");
printf ("If you are using a monochrome monitor, you may need to use the /m\n");
printf (" switch to inhibit color selections.\n\n");
printf ("The /p switch allows the operator to view and release files destined\n");
printf (" for %s%s\n\n", plotterserverstring, plotterstring);
}